//
//  MeViewController.m
//  1243
//
//  Created by 我的 on 16/3/22.
//  Copyright © 2016年 1243. All rights reserved.
//

#import "MeViewController.h"
#import "TableViewCell.h"
#import "LoginViewController.h"
#import "jiFenViewController.h"
#import "HeaderView.h"
#import "ZhangHuYuECell.h"
#import "ThreeButtonCell.h"
#import "XiaoFeiViewController.h"
#import "FenSiZhongXinTableViewController.h"
#import "ZhuanZhangViewController.h"
#import "BuyQuanViewController.h"
#import "ShopQuanViewController.h"
#import "ReadLoginData.h"
#import "gerAddressController.h"
#import "JudgeUserLogInTool.h"
#import "NetWorkTools.h"
#import "JiuDianHuiWuViewController.h"
#import "JiFenCycleViewController.h"
#import "WoDeFenSiTuanTableViewController.h"
#import "WithdrawalsViewController.h"
#import "PasswordTableViewController.h"
#import "VIPReginViewController.h"
#import "ModifyPersonalInformationViewController.h"
#import "TiCashViewController.h"
#import "ShoeBagDressViewController.h"
#import "MyOrderVC.h"
#import "ChongZhiViewController.h"
#import "SalesViewController.h"
#import "gerAddressController.h"
#import "BaseNavController.h"
#import "MerchantsApplyForVC.h"
#import "meiyongViewController.h"
#import "ShenQingKaiDianViewController.h"
#import "CollectViewController.h"
#import "ShenQingKaiDianViewController.h"
#import "FenxiaoCenterVC.h"

@interface MeViewController ()<UITableViewDataSource,UITableViewDelegate,UIAlertViewDelegate>
@property (nonatomic, strong)UITableView *tableView;
@property (nonatomic, strong)NSMutableArray *dataArr;
@property (nonatomic, strong)UIView *top;
@property (nonatomic, strong) HeaderView *headerView;

@property (nonatomic,strong) NSDictionary *loadUserData;

@property (nonatomic,copy)NSString *gouWuQuanCount;

@end

@implementation MeViewController

- (NSDictionary *)loadUserData {
    if (!_loadUserData) {
        _loadUserData = [NSDictionary dictionary];
    }
    return _loadUserData;
    
}

- (HeaderView *)headerView {
    
    if (!_headerView) {
        _headerView = [HeaderView loadHeaderView];
    }
    return _headerView;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self OtherNetWorkGet];
    
    NSDictionary *dict  = [ReadLoginData readLoginData];
     self.navigationController.navigationBar.translucent = YES;
//    self.automaticallyAdjustsScrollViewInsets = NO;
    if (dict.count) {
        // 已登录
        
    }else{
        //            LoginViewController *a = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:[NSBundle mainBundle]];
        //            [self presentViewController:a animated:YES completion:^{
        //
        //            }];
        
        [self releaseData];
        
    }
    
    
    
    self.dataArr = [[NSMutableArray alloc] init];
    [self.dataArr addObject:@"推荐新会员"];
    [self.dataArr addObject:@"我的点赚"];
    [self.dataArr addObject:@"粉丝中心"];
    [self.dataArr addObject:@"分销中心"];
    [self.dataArr addObject:@"地址管理"];
    [self.dataArr addObject:@"我的订单"];
    [self.dataArr addObject:@"我的收藏"];
    [self.dataArr addObject:@"咨询与反馈"];
    [self.dataArr addObject:@"申请开店"];
    [self loadGouWuQuanCount];
    [self loadNewData];
    NSLog(@"%@",self.loadUserData);
    
    
}


//BackData = "{\"Number\":1002,\"UserName\":\"13967120998\",\"Password\":\"111111\",\"Buy_Password\":\"222222\",\"RealName\":\"\U9648\U7acb\U6069\",\"Email\":\"\",\"V_Number\":1001,\"V_Name\":\"\U6768\U957f\U89c1\",\"LastLoginTime\":\"2016-02-15T12:00:06\",\"PNumber1\":1002,\"PName1\":\"\U9648\U7acb\U6069\",\"PNumber2\":1002,\"PName2\":\"\U9648\U7acb\U6069\",\"PNumber3\":0,\"PName3\":\"\",\"UserRole\":\"\U7b56\U7565\U59d4\",\"Money\":1409.0000,\"fh_Money\":68428.0000,\"gq_Money\":208072.8000,\"gwj_Money\":231922.6700,\"Dl_Money\":300.0000,\"Status\":1,\"CreateTime\":\"2015-12-01T20:12:21\",\"Remark\":\"101\"}"


- (void)loadNewData {
    
    
    if ([JudgeUserLogInTool  JudgeUserLonInStatus]){
        NSDictionary *dict = @{
                               @"PhoneNum":[ReadLoginData readLoginData][@"UserName"],
                               @"Password":[ReadLoginData readLoginData][@"Password"]
                               };
        
        [[NetWorkTools sharedNetWorkTools] objectWithURLDict:dict AndMenthodName:@"USERLOGIN" completeBlock:^(id object) {
            
            NSLog(@"%@",object);
            
            NSDictionary *loginDict = [NetWorkTools dictionaryWithJsonString:[object objectForKey:@"BackData"]];
            [self cleanloginData];
            [ReadLoginData savelogindataToLocal:loginDict];
            
            NSLog(@"%@",loginDict);
            
            self.loadUserData = [ReadLoginData readLoginData];
            
            [self.tableView reloadData];
            
            [self reloadHeaderViewData];
        }];
        
        //          BackData = "{\"InterLibray\":0.0000,\"Number\":1002,\"UserName\":\"13967120998\",\"Password\":\"111111\",\"Buy_Password\":\"111111\",\"RealName\":\"\U9648\U7acb\U6069\",\"Email\":\"\",\"V_Number\":1001,\"V_Name\":\"\U6768\U957f\U89c1\",\"LastLoginTime\":\"2016-02-15T12:00:06\",\"PNumber1\":1002,\"PName1\":\"\U9648\U7acb\U6069\",\"PNumber2\":1002,\"PName2\":\"\U9648\U7acb\U6069\",\"PNumber3\":0,\"PName3\":\"\",\"UserRole\":\"\U7b56\U7565\U59d4\",\"Money\":18377.5000,\"fh_Money\":10.0000,\"gq_Money\":208072.8000,\"gwj_Money\":231922.6700,\"Dl_Money\":300.0000,\"Status\":1,\"CreateTime\":\"2015-12-01T20:12:21\",\"Remark\":\"10000.0000\"}";
        
    }else{
        
        // [self pushLogin];
    }
    
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self creatViews];
    
    //    self.navigationItem.rightBarButtonItem = [UIBarButtonItem barButtonItemWithImage:[UIImage imageNamed:@"hy_set"] highImage:[UIImage imageNamed:@"hy_set"] target:self action:@selector(setBtn) imageEdgeInsets:UIEdgeInsetsMake(0, 35, 0, 0) titleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0) title:nil];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"ZhangHuYuECell" bundle:nil] forCellReuseIdentifier:@"ZhangHuCell"];
    [self.tableView registerNib:[UINib nibWithNibName:@"ThreeButtonCell" bundle:nil] forCellReuseIdentifier:@"ButtonCell"];
}

- (void)setBtn
{
    
}

- (void)loadGouWuQuanCount {
    
    
    if ([JudgeUserLogInTool  JudgeUserLonInStatus]){
        NSDictionary *dict = [ReadLoginData readLoginData];
        
        if (dict.count) {
            
            NSString *userId = [dict objectForKey:@"Number"];
            
            NSDictionary *params = @{
                                     @"UserNumber":userId
                                     };
            
            [[NetWorkTools sharedNetWorkTools] objectWithURLDict:params AndMenthodName:@"BUYCARDCOUNT" completeBlock:^(id object) {
                
                self.gouWuQuanCount = [object objectForKey:@"BackData"];
                
                [self.tableView reloadData];
            }];
        }
        
        
    }else{
        
        //   [self pushLogin];
    }
    
}

- (void)creatViews{
    self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    self.tableView.backgroundColor = [UIColor whiteColor];
    
    UIImageView *imageView = [[UIImageView alloc] init];
    //    imageView.image = [UIImage imageNamed:@"引导页1"];
    [imageView setFrame:self.headerView.bounds];
    [self.headerView addSubview:imageView];
    
    [self.headerView.LoginBtn addTarget:self action:@selector(clickLogin) forControlEvents:UIControlEventTouchUpInside];
    
    self.headerView.userImageV.layer.cornerRadius = 30;
    self.headerView.userImageV.layer.masksToBounds = YES;
    //    self.headerView.backgroundColor = [UIColor colorWithRed:44 / 255.0 green:87 / 255.0 blue:229 / 255.0 alpha:1];
#warning 修改个人中心蓝色背景
    self.tableView.tableHeaderView = self.headerView;
    
}

#pragma mark - 点击登录按钮
- (void)clickLogin {
    
    if ([ReadLoginData readLoginData].count) {
        
        
        ModifyPersonalInformationViewController *vc = [[ ModifyPersonalInformationViewController alloc] init];
        
        [self pushForm:self.navigationController pushToAndHidden:vc];
        
    } else {
        //         未登录 跳出登录
        //  [self presentViewController:[[LoginViewController alloc] init] animated:YES completion:nil];
        // [self.navigationController pushViewController:[[LoginViewController alloc] init] animated:YES];
        [self pushLogin];
        
    }
    //
    
    
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    
    //    if (alertView.tag == 210) {
    //        NSLog(@"%ld",buttonIndex)
    if (alertView.tag == 2000) {
        
    }else if (alertView.tag == 12178){
        if (buttonIndex == 0) {
            [self netWorkTools:@"0"];
        }else{
            
        }
        
        
    }else if (alertView.tag == 12179){
        if (buttonIndex == 0) {
            [self netWorkTools:@"1"];
        }else{
            
        }
    }
    else{
        
        if (buttonIndex == 0) {
            [self releaseData];
            
        } else {
            [self reloadHeaderViewData];
        }
    }
   
    
    //    }
    
}

- (void)releaseData
{
    [self cleanloginData];
    [ReadLoginData removeDataToLocal:@"addressData.plist"];
    [ReadLoginData removeDataToLocal:@"shopData.plist"];
    self.loadUserData = nil;
    [self.tableView reloadData];
    [self reloadHeaderViewData];
}

- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex {
    
    NSLog(@"%ld",self.loadUserData.count);
    [self.tableView reloadData];
}



- (void)cleanloginData {
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
    NSString *path=[paths objectAtIndex:0];
    //    NSLog(@"path = %@",path);
    NSString *filename=[path stringByAppendingPathComponent:@"loginData.plist"];
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] initWithCapacity:0];
    [dic writeToFile:filename atomically:YES];
    
}

#pragma mark - UITableView Data Source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 4;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 3) {
        return self.dataArr.count;
    }
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0 || indexPath.section == 1) {
        
        ZhangHuYuECell *cell = [tableView dequeueReusableCellWithIdentifier:@"ZhangHuCell" forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        if (indexPath.section == 0) {
            
            if (self.loadUserData.count) {
                cell.numLabel.text = [NSString stringWithFormat:@"%.2f",[[self.loadUserData objectForKey:@"Money"] floatValue]];
                
            } else {
                cell.numLabel.text = @"0.00";
            }
            //            [cell.jiFenJiaoYiButton setTitle:@"酒店会晤" forState:UIControlStateNormal];
            //            [cell.jiFenJiaoYiButton addTarget:self action:@selector(didClickJiuDianHuiWuButton) forControlEvents:UIControlEventTouchUpInside];
            //转账
            [cell.leftButton addTarget:self action:@selector(zhuanzhangBtn) forControlEvents:UIControlEventTouchUpInside];
            
            //积分赠送
            [cell.centerButton addTarget:self action:@selector(jifenZengsong) forControlEvents:UIControlEventTouchUpInside];
            
            //充值
            [cell.rightButton addTarget:self action:@selector(RechargeBtn) forControlEvents:UIControlEventTouchUpInside];
            [cell.NewBtn addTarget:self action:@selector(NewBtn) forControlEvents:UIControlEventTouchUpInside];
            // 购买代金卷
            [cell.MoneyGouMaiDaiJinJuan addTarget:self action:@selector(MoneyGouMaiDaiJinJuan) forControlEvents:UIControlEventTouchUpInside];
            
            [cell.rightButton setTitle:@"充值" forState:UIControlStateNormal];
            [cell.centerButton setImage:[UIImage imageNamed:@"jfzszq"] forState:UIControlStateNormal];
        } else {
            cell.titleName.text = @"当前积分：";
            if (self.loadUserData.count) {
                cell.numLabel.text = [NSString stringWithFormat:@"%.2f",[[self.loadUserData objectForKey:@"gq_Money"] floatValue]];
            } else {
                cell.numLabel.text = @"0.00";
            }
            //            [cell.jiFenJiaoYiButton setTitle:@"积分交易" forState:UIControlStateNormal];
            //            [cell.jiFenJiaoYiButton addTarget:self action:@selector(didClickJiFenJiaoYiButton) forControlEvents:UIControlEventTouchUpInside];
            //消费
            [cell.leftButton setTitle:@"积分消费" forState:UIControlStateNormal];
            [cell.leftButton addTarget:self action:@selector(xiaofeiBtn) forControlEvents:UIControlEventTouchUpInside];
            [cell.leftButton setImage:[UIImage imageNamed:@"hy_xiaofei"] forState:UIControlStateNormal];
            
            //商品列表
            [cell.centerButton addTarget:self action:@selector(jiFenZhuanQu) forControlEvents:UIControlEventTouchUpInside];
            cell.label.hidden = YES;
            [cell.centerButton setTitle:@"特价兑换区" forState:UIControlStateNormal];
            [cell.centerButton setImage:[UIImage imageNamed:@"splb"] forState:UIControlStateNormal];
            // icon_qyq
            
            //            cell.NewBtn.hidden = YES;
#warning 设置企业券
            [cell.NewBtn setImage:[UIImage imageNamed:@"icon_qyq"] forState:UIControlStateNormal];
            [cell.NewBtn setTitle:@"企业券" forState:UIControlStateNormal];
            [cell.NewBtn addTarget:self action:@selector(didCLickQiYeQuanButton) forControlEvents:UIControlEventTouchUpInside];
            
            [cell.rightButton setImage:[UIImage imageNamed:@"jifenzhuanpan"] forState:UIControlStateNormal];
            
            //积分转盘
            [cell.rightButton setTitle:@"积分转盘" forState:UIControlStateNormal];
            [cell.rightButton addTarget:self action:@selector(jifenCycleBtn) forControlEvents:UIControlEventTouchUpInside];
            
            // 购买代金卷
            [cell.MoneyGouMaiDaiJinJuan addTarget:self action:@selector(MoneyGouMaiDaiJinJuanA) forControlEvents:UIControlEventTouchUpInside];
        }
        
        return cell;
    } else if (indexPath.section == 2) {
        ThreeButtonCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ButtonCell" forIndexPath:indexPath];
        if (self.loadUserData.count) {
            
            cell.GouWuQuanLabel.text = [NSString stringWithFormat:@"%@",self.gouWuQuanCount];
            
            cell.jifenKuLabel.text = [NSString stringWithFormat:@"%.2f",[[self.loadUserData objectForKey:@"InterLibray"] floatValue]];
            
            
        } else {
            
            cell.GouWuQuanLabel.text = @"0.00";
            cell.jifenKuLabel.text = @"0.00";
        }
        
        //购物券
        [cell.ShopQuanBtn addTarget:self action:@selector(shopQuanBtn) forControlEvents:UIControlEventTouchUpInside];
        
        //积分库
        [cell.jifenKuButton addTarget:self action:@selector(jifenKuButtonClick) forControlEvents:UIControlEventTouchUpInside];
        return cell;
        
    } else {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mine"];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"mine"] ;
        }
        
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        cell.textLabel.text= self.dataArr[indexPath.row];
        cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"hy_icon_%ld",(long)(indexPath.row)]];
        cell.textLabel.font = [UIFont systemFontOfSize:15];
        return cell;
    }
}
- (void)MoneyGouMaiDaiJinJuan{
    
    if ([JudgeUserLogInTool  JudgeUserLonInStatus]){
        
        UIAlertView *alview = [[UIAlertView alloc] initWithTitle:@"提示" message:@"请确认购买" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil];
        alview.tag = 12178;
        [alview show];
        
//        [self netWorkTools:@"0"];
    }else{
        [self pushLogin];
    }
    
    
}
- (void)MoneyGouMaiDaiJinJuanA{
      if ([JudgeUserLogInTool  JudgeUserLonInStatus]){
          UIAlertView *alview = [[UIAlertView alloc] initWithTitle:@"提示" message:@"请确认购买" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil];
          alview.tag = 12179;
          [alview show];
//            [self netWorkTools:@"1"];
      }else{
            [self pushLogin];
      }
  
    
}
- (void)netWorkTools:(NSString *)str{
    NSDictionary *dict = [ReadLoginData readLoginData];
    NSString *userNumber = [dict objectForKey:@"Number"];
    NSDictionary *params = @{
                             @"UserNumber":userNumber,
                             @"ProductNumber":@"1",
                             @"Type":str
                             };
    //   GUANG GAO FEN HONG HUO XIAN JIN TI XIAN
    [[NetWorkTools sharedNetWorkTools] objectWithURLDict:params AndMenthodName:@"BUYCARD" completeBlock:^(id object) {
        NSString *str = [object objectForKey:@"Message"];
        NSLog(@"购买代金卷%@",object);
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:str delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        alert.tag = 2000;
        [alert show];
    }];
}

- (void)didCLickQiYeQuanButton {
    if ([JudgeUserLogInTool  JudgeUserLonInStatus]){
        meiyongViewController *sales = [[meiyongViewController alloc] init];
        //        [self.navigationController pushViewController:a animated:YES];
        [self pushForm:self.navigationController pushToAndHidden:sales];
        
    }else{
        
        [self pushLogin];
    }
    
}

- (void)NewBtn{
    
    
    if ([JudgeUserLogInTool  JudgeUserLonInStatus]){
        TiCashViewController *a = [[TiCashViewController alloc] init];
        //        [self.navigationController pushViewController:a animated:YES];
        [self pushForm:self.navigationController pushToAndHidden:a];
        
    }else{
        [self pushLogin];
    }
    
}

- (void)didClickJiuDianHuiWuButton {
    
    if ([JudgeUserLogInTool  JudgeUserLonInStatus]) {
        JiuDianHuiWuViewController *huiWu = [[JiuDianHuiWuViewController alloc] init];
#warning 会晤跳转
        [self pushForm:self.navigationController pushToAndHidden:huiWu];
        
    }else{
        [self pushLogin];
    }
}

- (void)didClickJiFenJiaoYiButton {
    
    if ([JudgeUserLogInTool  JudgeUserLonInStatus]) {
        XiaoFeiViewController *xiaoVC = [[XiaoFeiViewController alloc] init];
        
        xiaoVC.GuangGaoFenHongLabel.text = [NSString stringWithFormat:@"%.2f",[[self.loadUserData objectForKey:@"gq_Money"] floatValue]];
        
        [self pushForm:self.navigationController pushToAndHidden:xiaoVC];
        
    }else{
        
        [self pushLogin];
    }
}

- (void)reloadHeaderViewData {
    if (self.loadUserData.count) {
        NSInteger status = [[self.loadUserData objectForKey:@"Status"] integerValue];
        if (status == 0) {
            self.headerView.JiHuoZhuangTai.text = @"未激活";
        } else if (status ==1) {
            self.headerView.JiHuoZhuangTai.text = @"已激活";
        } else {
            self.headerView.JiHuoZhuangTai.text = @"已锁定";
        }
        
        NSString *Time = [self.loadUserData objectForKey:@"CreateTime"];
        Time = [Time stringByReplacingOccurrencesOfString:@"T" withString:@" "];
        self.headerView.SuoDingShiJian.text = [NSString stringWithFormat:@" %@",Time];
        
        NSString *userName = [self.loadUserData objectForKey:@"RealName"];
        if ([userName isEqualToString:@""]) {
            self.headerView.NameLabel.text = @"昵称";
        } else {
            self.headerView.NameLabel.text = [userName stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        }
        
        self.headerView.HuiYuanZhuangTai.text = [NSString stringWithFormat:@"%@", [self.loadUserData objectForKey:@"UserRole"]];
        
    } else {
        self.headerView.JiHuoZhuangTai.text = @"未激活";
        self.headerView.SuoDingShiJian.text = @"锁定时间: ";
        self.headerView.NameLabel.text = @"昵称";
        self.headerView.HuiYuanZhuangTai.text = @"账户类型";
        
    }
    
}

#pragma mark - UITableView Delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    //
    
    if ([JudgeUserLogInTool  JudgeUserLonInStatus]) {
        
        if (indexPath.section == 0 || indexPath.section == 1) {
            
            
        }else{
            
            if (indexPath.row == 0) {
                //            推荐会
                VIPReginViewController *a = [[VIPReginViewController alloc]  init];
                [self pushForm:self.navigationController pushToAndHidden:a];
                
            }else if (indexPath.row == 1){
                //我的点赚
                
            }else if (indexPath.row == 2) {
                //            粉丝中心
                [self pushForm:self.navigationController pushToAndHidden:[[FenSiZhongXinTableViewController alloc] init]];
                
            }else if (indexPath.row == 3) {
                //            分销中心
                NSLog(@"分销中心");
                FenxiaoCenterVC *vc = [[FenxiaoCenterVC alloc]init];
                [self pushForm:self.navigationController pushToAndHidden:vc];
                
            }else if (indexPath.row == 4) {
                //地址管理
                gerAddressController *address = [[gerAddressController alloc] init];
                address.pageIndex = 1;
                [self pushForm:self.navigationController pushToAndHidden:address];
                
            }else if (indexPath.row == 5) {
                //            我的订单
                MyOrderVC *order = [[MyOrderVC alloc] init];
                
                [self pushForm:self.navigationController pushToAndHidden:order];
                
            }else if (indexPath.row == 6) {
                //我的收藏
                //            jiFenViewController *jifen = [[jiFenViewController alloc] init];
                //            [self pushForm:self.navigationController pushToAndHidden:jifen];
                
                CollectViewController *collectVC = [[CollectViewController alloc] init];
                [self pushForm:self.navigationController pushToAndHidden:collectVC];
            }else if(indexPath.row == 7) {
                //咨询与反馈
                
            }else{
                
          //    ShenQingKaiDianViewController   *merVc = [[ShenQingKaiDianViewController alloc] init];

                // 申请开店
                ShenQingKaiDianViewController *a = [[ShenQingKaiDianViewController alloc] initWithNibName:@"ShenQingKaiDianViewController" bundle:[NSBundle mainBundle]];
                [self pushForm:self.navigationController pushToAndHidden:a];
            }
            
            
        }
        
        
        
        
    }else{
        
        [self pushLogin];
    }
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}

- (void)button{
    
    
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0 || indexPath.section == 1) {
        return 100;
    }
    return 50;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark >>>>>>>>>> cell button点击事件
- (void)zhuanzhangBtn {
    if ([JudgeUserLogInTool  JudgeUserLonInStatus]){
        ZhuanZhangViewController *zzVC = [[ZhuanZhangViewController alloc] init];
        
        [self pushForm:self.navigationController pushToAndHidden:zzVC];
        
    }else{
        
        [self pushLogin];
    }
}
// 消费Button
- (void)xiaofeiBtn {
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"DidClickXiaoFeiButtonChangeTabBarControllerSelected" object:nil userInfo:nil];
}

/**
 *  积分赠送专区
 */
#warning 传入购物券购买Type
- (void)jifenZengsong
{
    if ([JudgeUserLogInTool  JudgeUserLonInStatus]) {
        
        //        BuyQuanViewController *buyVC = [[BuyQuanViewController alloc] init];
        
        //        buyVC.buyType = @"0";
        
        
        ShoeBagDressViewController *shoeVc = [[ShoeBagDressViewController alloc] init];
        shoeVc.str = @"积分赠送专区";
        shoeVc.payIndex = 1;
        [self pushForm:self.navigationController pushToAndHidden:shoeVc];
    }else{
        
        [self pushLogin];
    }
}

//充值
- (void)RechargeBtn
{
    NSLog(@"充值");
    
    
    
    if ([JudgeUserLogInTool  JudgeUserLonInStatus]) {
        
        ChongZhiViewController *ChongZhiVc = [[ChongZhiViewController alloc] init];
        ChongZhiVc.payPassword = self.loadUserData[@"Buy_Password"];
        [self pushForm:self.navigationController pushToAndHidden:ChongZhiVc];

        
    }else{
        
        [self pushLogin];
    }
    NSLog(@"积分转盘");

}

- (void)jifenCycleBtn
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"6月6日正式启动，敬请期待！" delegate: nil cancelButtonTitle:@"确定" otherButtonTitles: nil, nil];
//    [alert show];
    if ([JudgeUserLogInTool  JudgeUserLonInStatus]) {
        
        JiFenCycleViewController *jifen = [[JiFenCycleViewController alloc] init];
        
       [self pushForm:self.navigationController pushToAndHidden:jifen];
        
    }else{
        [self pushLogin];
    }
    NSLog(@"积分转盘");
    
}

- (void)jifenKuButtonClick
{
    NSLog(@"积分库");
    
    
}

#warning 传入购物券购买Type
//积分专区
- (void)jiFenZhuanQu {
    
        if ([JudgeUserLogInTool  JudgeUserLonInStatus]) {
    
            ShoeBagDressViewController *shoeVc = [[ShoeBagDressViewController alloc] init];
            shoeVc.str = @"积分专区";
            shoeVc.payIndex = 1;
            [self pushForm:self.navigationController pushToAndHidden:shoeVc];
    
        }else{
    
            [self pushLogin];
        }
    
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"6月6日正式启动,敬请期待!" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
  //  [alert show];
    
}

- (void)shopQuanBtn
{
    if ([JudgeUserLogInTool  JudgeUserLonInStatus]) {
        ShopQuanViewController *shopVC = [[ShopQuanViewController alloc] init];
        [self pushForm:self.navigationController pushToAndHidden:shopVC];
    }else{
        
        [self pushLogin];
    }
}

//tabBar 隐藏
- (void)pushForm:(UINavigationController *)pushForm pushToAndHidden:(UIViewController *)pushToVC
{
    [pushToVC setHidesBottomBarWhenPushed:YES];
    [pushForm pushViewController:pushToVC animated:YES];
    
}

- (void)pushLogin
{
    LoginViewController *a = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:[NSBundle mainBundle]];
    BaseNavController *baseNav = [[BaseNavController alloc] initWithRootViewController:a];
    [self presentViewController:baseNav animated:YES completion:nil];
//    [self pushForm:self.navigationController pushToAndHidden:a];
}

- (void)OtherNetWorkGet{
    
    NSDictionary *params = @{
                             @"MenthodParms":@"",
                             @"Sign":@"CB2E8A4922AF3992A8AE776A4230D9C3E33DD5A0"
                             };
    [[NetWorkTools sharedNetWorkTools] objectWithURLDict:params AndMenthodName:@"QUEYMERCAHNTCONFIG" completeBlock:^(id object) {
        NSString *str = [object objectForKey:@"BackData"];
        NSArray *arr = [NetWorkTools arrayWithJsonString:str];
        NSLog(@"QUEYMERCAHNTCONFIG%@",arr);
        [ReadLoginData saveZhuanPanToLocal:arr];
        
        
    }];
    
    
}


@end
